#include<bits/stdc++.h>
using namespace std;
struct node{
	int no;
	int num;
	bool flag;
}a[100];
int main(){
	for(int i = 0; i < 100; i++){
		a[i].no = i+1;
		a[i].num = 5 - (i%5);
		a[i].flag = 0;
	}
	int n;
	cin >> n;
	while(n--){
		int p;
		cin >> p;
		int mark = 0;
		int q = p;
		for(int i = 0;i < 100 && q > 0;i++){
			if(a[i].flag == 0 && a[i].num >= p){
				for(int j = i; j < i + p -1; j++){
					cout << a[j].no << " ";
					a[j].flag = 1;
					q--;
				}
				cout << a[i+p-1].no << endl;
				a[i+p-1].flag = 1;
				mark = 1;
				q--;
			}
		}
		if(mark == 0)
		for(int i = 0;i < 100 && p > 0;i++){
			if(a[i].flag == 0 && p > 1){
				cout << a[i].no << " ";
				p--;
			}else if(a[i].flag == 0 && p == 1){
				cout << a[i].no <<endl;
				p--;
			}
		}
	}
}
